﻿using Rougamo;
using Rougamo.Context;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RougamoAgent
{
    public class LoggingAttribute:MoAttribute
    {
        public override void OnEntry(MethodContext context)
        {
            // 从context对象中能取到包括入参、类实例、方法描述等信息
            Console.WriteLine("执行请的操作，准备数据等");
            base.OnEntry(context);
        }

        public override void OnException(MethodContext context)
        {
            Console.WriteLine("我这边异常了，请注意哦");
            base.OnException(context);
        }

        //
        public override void OnSuccess(MethodContext context)
        {
            Console.WriteLine("方法执行后");
            base.OnSuccess(context);
        }

        public override void OnExit(MethodContext context)
        {
            Console.WriteLine("方法退出时，不论方法执行成功还是异常，都会执行");
        }
    }
}
